<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="manage" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<manage:page title="配送价格管理">
     <jsp:attribute name="script">
         <script type="text/javascript" src="static-resources/layer/layer.js"></script>
         <script type="text/javascript" >
         function submitNormal() {
             $.ajax({
                 type:"POST",
                 url:"${pageContext.request.contextPath}/deliveryPrice/update.do",
                 data:{
                     "deliveryFee":$("#normalPrice").val()*100,
                     "deliveryPriority":"PRIORITY_NORMAL",
                     "id":$("#normal").val()
                 },
                 dataType:"json",
                 success:function (data) {
                     if (data && data.code == 0){
                         $("#normal").val(data.data.id),
                         alert("操作成功")
                     }else {
                         alert("操作失败")
                     }
                 }
             })
         }
         function submitImmediate() {
             $.ajax({
                 type:"POST",
                 url:"${pageContext.request.contextPath}/deliveryPrice/update.do",
                 data:{
                     "deliveryFee":$("#immediatePrice").val()*100,
                     "deliveryPriority":"PRIORITY_IMMEDIATE",
                     "id":$("#immediate").val()
                 },
                 dataType:"json",
                 success:function (data) {
                    if(data && data.code == 0) {
                        $("#immediate").val(data.data.id),
                        alert("操作成功")
                    }else {
                        alert("操作失败")
                    }
                 }
             })
         }

         </script>
</jsp:attribute>
    <jsp:body>
        <div class="ui container" style="display: block;margin-top: 5px;">
        <br>
        <div class="ui breadcrumb">
            <a class="active section" href="/delivery.do">配送价格管理</a>
        </div>
        <div class="ui container">
            <table class="ui striped table" >
                <tr>
                    <th>
                        <h4>配送类型</h4>
                    </th>
                    <th style="display:none">
                        <h4>id)</h4>
                    </th>
                    <th>
                        <h4>价格(元)</h4>
                    </th>
                    <th>
                        <h4>操作</h4>
                    </th>
                    </tr>
                    <tr >
                        <td>立即送
                          <input type="hidden" id="immediate" name="id" value="${deliveryFeeVoImmediate.id}" >
                        </td>

                        <td>
                        <input type="number" id="immediatePrice" placeholder="价格(元)" name="deliveryFee" value="${(deliveryFeeVoImmediate.deliveryFee)/100}">
                        </td>
                        <td>
                            <input type="submit" value="确定" onclick="submitImmediate()">
                        </td>
                    </tr>
                <tr >
                    <td>普通送<input type="hidden" id="normal" name="id" value="${deliveryFeeVoNormal.id}"></td>
                    <td>
                        <input type="number" id="normalPrice" placeholder="价格(元)" name="deliveryFee" value="${(deliveryFeeVoNormal.deliveryFee)/100}" >
                    </td>
                    <td>
                        <input type="button" id="normalSubmit" value="确定" onclick="submitNormal()">
                    </td>
                </tr>
            </table>
        </div>
    </jsp:body>
</manage:page>
